package class01;

public class StringMethodTest {
    public static String heroNameZN = "孙悟空";
    public static String heroNameEN = "sunwukong";


    public static void main(String[] args) {
        //    系列1：常用方法
        //
        //（1）boolean isEmpty()：字符串是否为空
        System.out.println(heroNameZN.isEmpty());
        System.out.println(heroNameEN.isEmpty());
        System.out.println("".isEmpty());
        //（2）int length()：返回字符串的长度
        System.out.println(heroNameZN.length());
        System.out.println(heroNameEN.length());
        //（3）String concat(xx)：拼接
        System.out.println(heroNameZN.concat("，你好"));
        System.out.println(heroNameEN.concat("，hello"));
        //（4）boolean equals(Object obj)：比较字符串是否相等，区分大小写
        System.out.println(heroNameZN.equals(heroNameEN));
        //（5）boolean equalsIgnoreCase(Object obj)：比较字符串是否相等，不区分大小写
        System.out.println("A".equalsIgnoreCase("a"));
        //（6）int compareTo(String other)：比较字符串大小，区分大小写，按照Unicode编码值比较大小   负数：前值字符串小，正数：前值字符串大，0：相等
        System.out.println("A".compareTo("a"));
        //（7）int compareToIgnoreCase(String other)：比较字符串大小，不区分大小写    负数：前值字符串小，正数：前值字符串大，0：相等
        System.out.println("A".compareToIgnoreCase("a"));
        //（8）String toLowerCase()：将字符串中大写字母转为小写
        String s1= "     AAAAAnnnnMMMM          ";
        System.out.println(s1.toLowerCase());

        //（9）String toUpperCase()：将字符串中小写字母转为大写
        System.out.println(heroNameEN.toUpperCase());
        //（10）String trim()：去掉字符串前后空白符
        System.out.println(s1.trim());
        //（11）public String intern()：结果在常量池中共享
        String intern = s1.intern();
        System.out.println(intern);

    }


}
